package com.qf.main.pharmacy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.common.db.utils.CommonBeanutils;
import com.qf.main.pharmacy.common.qo.AuditQo;
import com.qf.main.pharmacy.common.vo.AuditVo;
import com.qf.main.pharmacy.common.vo.OrderVo;
import com.qf.main.pharmacy.common.vo.PharmacyVO;
import com.qf.main.pharmacy.entity.Audit;
import com.qf.main.pharmacy.entity.Pharmacy;
import com.qf.main.pharmacy.mapper.AuditMapper;
import com.qf.main.pharmacy.service.AuditService;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author chengqiang
 * @Create 2024-03-03-14:18
 * @Description:
 */
@Service
public class AuditServiceImpl implements AuditService {

    @Resource
    private AuditMapper auditMapper;

    @Override
    public Integer saveAudit(AuditQo auditQo) {
        Audit audit = CommonBeanutils.convertTo(auditQo, Audit::new);
        return auditMapper.insert(audit);
    }

    @Override
    public List<AuditVo> orderByIdList(int pageNum, int pageSize, int id) {
        return null;
    }

    @Override
    public PageInfo<AuditVo> auditList(Integer pageNum , Integer pageSize, Integer resource) {
        QueryWrapper<Audit> qw = new QueryWrapper<>();
        qw.eq(resource!=null,Audit.COL_RESOURCE,resource);
        PageInfo<AuditVo> PageInfo = PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(
                () -> CommonBeanutils.convertTo(auditMapper.selectList(qw),AuditVo::new));
        return PageInfo;
    }

    @Override
    public Integer modifyAudit(AuditQo auditQo) {
        Audit audit = CommonBeanutils.convertTo(auditQo, Audit::new);
        return auditMapper.updateById(audit);
    }

    @Override
    public Integer removeAudit(int id) {

        return auditMapper.deleteById(id);
    }
}
